/*-------------------------------------------------------------------------
	created:	2010/09/15  10:51
	filename: 	e:\Project_SVN\Server\ServerDemo\Interface\GameInterface.h
	author:		Deeple

	purpose:
---------------------------------------------------------------------------*/

#pragma once

#include "GameType.h"

class IGame
{
public:
	// 配置操作
	// ------------------------------------------------------------------------------
	// 重新加载配置文件
	virtual bool ReloadConfig() = 0;

	// 获取服务器程序所在路径
	virtual const char* GetAppPath() = 0;

	// 获取资源目录所在路径
	virtual const char* GetResourcePath() = 0;

	// 获取服务器名字
	virtual const char* GetServerName() = 0;

	// 获取服务器id
	virtual UI32 GetServerID() = 0;

	// 查询服务器当前心跳数
	virtual UI32 GetSysHeartBeat() = 0;

	// 获取缓冲申请器
	virtual IBufAllocator* GetBufAllocator() = 0;

	// 获取系统时间, time_stamp = 0 表示当前时间
    virtual void GetLocalTime(struct tm* t, time_t time_stamp = 0) = 0;

	// 游戏世界通用功能(通信部分)
	// ------------------------------------------------------------------------------
	// 关闭服务器
	virtual void QuitServer() = 0;

	// 发送命令给一个对象(可以跨场景)
	virtual bool SendCommand(UI32 sender, UI32 receiver, UI32 msgType, CMsgTyped* pmsg) = 0;

	// 发送命令到所有玩家
    virtual void CommandToWorld(UI32 sender, UI32 msgType, CMsgTyped* pmsg) = 0;

    // 发送命令到场景对象
	virtual void CommandToScene(UI32 sender, UI32 msgType, CMsgTyped* pmsg, GameType destType = GAME_NONE) = 0;

	// 断开玩家
	virtual bool DisconnectPlayer(UI32 nPlayerId) = 0;

	// 断开玩家
	virtual bool DisconnectPlayer(const char* szName) = 0;

	// 发送客户端消息
	virtual bool Custom(UI32 playerId, UI32 msgType, CMsgTyped* pmsg) = 0;

	// 发送客户端消息
	virtual bool Custom(const char* szName, UI32 msgType, CMsgTyped* pmsg) = 0;

	// 广播到所有人
	virtual bool CustomToWorld(UI32 msgType, CMsgTyped* pmsg) = 0;

	// 广播到场景
	virtual bool CustomToScene(UI32 sceneId, UI32 msgType, CMsgTyped* pmsg) = 0;

	// 广播到场景其它人
	virtual bool CustomToSceneMate(UI32 self, UI32 msgType, CMsgTyped* pmsg) = 0;

	// 广播到区域
	virtual bool CustomToArea(RECT rc, UI32 msgType, CMsgTyped* pmsg) = 0;

	// 广播到列表
	virtual bool CustomToList(UI32 players[], int count, UI32 msgType, CMsgTyped* pmsg) = 0;

	// 广播到视野(视野范围由玩家配置文件的vwidth和vheight决定)
	virtual bool CustomToSight(int centerX, int centerY, UI32 msgType, CMsgTyped* pmsg) = 0;
	virtual bool CustomToSight(UI32 target, UI32 msgType, CMsgTyped* pmsg) = 0;

	// 发送公共服务器消息， sender 可以是具体对象， 或者0(表示系统), 回调消息将会发给发送者
	virtual bool SendGlobalMessage(int index, UI32 sender, UI32 msgId, CMsgTyped* pmsg) = 0;

	// 游戏世界通用功能(功能部分)
	// ------------------------------------------------------------------------------
	// 创建计时器
	virtual bool CreateTimer(UI32 target, UI32 timer_id, UI32 interval_minisec,
		UI32 repeat = 1, CMsgTyped* pmsg = NULL) = 0;

	// 获取场景id
	virtual UI32 GetCurrentSceneId() = 0;

	// 场景是公共场景
	virtual SceneType GetCurrentSceneType() = 0;

	// 场景是否公共场景
	virtual SceneType GetSceneType(UI32 sceneMod) = 0;

	// 获取场景模板id
	virtual UI32 GetCurrentSceneMod() = 0;

	// 获取场景所在副本线程id
	virtual UI32 GetCurrentSceneThread() = 0;

    // 获取玩家所在场景的pScene
	virtual IGame* GetCurrentScenePtr() = 0;

	// 获取场景列表, sceneMod = 0 表示获取当前场景房间列表
	virtual void GetRoomList(UI32 sceneMod, UI32 sceneList[], int& size) = 0;

	// 获取当前场景的编号,  参数sceneMod 0 表示获取当前场景编号
	virtual UI32 GetRoomNumber(UI32 sceneMod = 0, UI32 sceneId = 0) = 0;

	// 获取当前副本参数
	virtual bool GetCopyThreadParam(COPY_THREAD_PARAM* param) = 0;

	// 获副本场景列表,
	virtual bool GetCopyList(UI32 threadId, UI32 sceneList[], int& size) = 0;

	// 锁定副本， 锁定后玩家无法随机加入
	virtual bool LockCopy(bool lock = true) = 0;

	// 获取场景默认登录点
	virtual void GetLandingPosi(OBJ_POS* location) = 0;

	// 查找玩家
	virtual UI32 LocalFindPlayer(const char* szPlayer) = 0;

	// 查找玩家
	virtual const char* LocalFindPlayer(UI32 playerId) = 0;

	// 查找玩家
	virtual UI32 GlobalFindPlayer(const char* szPlayer) = 0;

	// 查找玩家
	virtual const char* GlobalFindPlayer(UI32 playerId) = 0;

	// 获取玩家信息
	virtual bool GetUserStat(UI32 playerId, UserInfo* info) = 0;

	// 获取玩家延迟(返回 -1 表示失败)
	virtual UI32 GetDelayMiniSecs(UI32 playerId) = 0;

	// 设置,获取角色等级
	virtual bool SetPlayerLevel(UI32 playerId, int level) = 0;
	virtual int GetPlayerLevel(UI32 playerId) = 0;

	// 查询单个角色的状态，查询结束后， 调用fun处理数据
	// nameList格式， SetInt(名字数量) + 循环 SetString(名字)
    // para 在回调中使用， 一般传递一个json即可
    // 返回值结构
    // @1 name          string
    // @1 guid          string
    // @3 server_id     int
    // @4 lastLoginTm   int
    // @5  save_para    string
	virtual bool QueryPlayerStates(UI32 sender,CMsgTyped& nameList, LPQUERYROLEFUN fun, const char* para = NULL) = 0;

	// 将GUID翻译成名字，查询结束后， 调用fun处理数据
	// nameList格式， int(guid数量) + 循环n次 string(循环每一个guid)
    // para 在回调中使用， 一般传递一个json即可
    // 返回值结构
    // @1 guid  string
    // @2 name  string
	virtual bool GuidToName(UI32 sender,CMsgTyped& nameList, LPQUERYROLEFUN fun, const char* para = NULL) = 0;

	// 随机查找玩家
	virtual void RandomFindPlayers(FindPlayerStruct find[], int& size, int levelFrom = 0, int levelTo = 9999) = 0;

	// 发送投诉
	virtual bool SendGmRequest(int nType, const char* szPlayer, const char* szTitle, const char* szContent, int nLevel, int nJob) = 0;

	// 创建处理器
	virtual bool AddProcessor(int id, const char* szProcessorName, size_t nThreadCount, const char* szADOConnStr) = 0;

	// 查找处理机
	virtual CAsyncProcesser* FindProcessor(int nProcessorID) = 0;

	// 查找处理机
	virtual CAsyncProcesser* FindProcessor(const char* szProcessorName) = 0;

	// 注册工作
	virtual bool Call(int nProcessorId, LPASYNCPROCFUNC func, CMsgTyped* pParamList) = 0;

	// 注册工作
	virtual bool Call(const char* szProcessorName, LPASYNCPROCFUNC func, CMsgTyped* pParamList) = 0;

	// 删除处理机
	virtual bool RemoveProcessor(int nProcessorID) = 0;

	// 删除处理机
	virtual bool RemoveProcessor(const char* szProcessorName) = 0;

	// 模块管理
	// 模块间注册C函数. name 不能为空， id为0-1023(-1 表示系统分配id)
    virtual bool ModRegisterFunc(const char* name, int id, LPMODULEFUN fun) = 0;
    virtual bool ModCall(const char* name, void* pParam) = 0;
    virtual bool ModCall(int id, void* pParam) = 0;

	// LUA
	virtual int LuaGetInt(const char* var_name) = 0;
	virtual bool LuaGetBool(const char* var_name) = 0;
	virtual float LuaGetFloat(const char* var_name) = 0;
	virtual double LuaGetDouble(const char* var_name) = 0;
	virtual const char* LuaGetString(const char* var_name) = 0;

	// calllua , 返回-1 表示调用失败，返回0表示成功
	virtual bool LuaCall(const char* func, CMsgTyped& param) = 0;
	virtual void LuaRegisterFunc(const char* funcName, LuaFun func) = 0;

	// 角色冻结
	// -------------------------------------------------------------------------------
    virtual void FreezeAccount(const char* account, time_t toDate) = 0;
    virtual void FreezeIP(const char* ip, time_t toDate) = 0;
    virtual bool UnFreezeAccount(const char* account) = 0;
    virtual bool UnFreezeIP(const char* ip) = 0;

	// 对象操作功能
	// -------------------------------------------------------------------------------
	// 获取对象信息
	// 创建对象
	virtual UI32 CreateObject(UI32 typeId, float posi_x,float posi_y,
		float posi_z, OBJ_POSI_INFO* move_param = NULL, int reason = SR_NONE) = 0;

    // 创建公共对象
    virtual bool CreatePublicObject(UI32 creator, UI32 typeId,  bool bSave,
                                    const char* name = NULL, const char* save_para=NULL, LPCREATEPUBOBJFUN fun=NULL, const char* para=NULL) = 0;

    // 创建房间
    // lingerSeconds 如果没有玩家进入, 副本能保留的时间, 填0表示系统默认
    // maxPlayers 最大支持人数，填0表示系统默认
    // 房间难度信息和其他信息可以放到params 中
    // CallBack 填 NULL 将不掉用回调
    // 可以创建主场景和副本
    virtual void CreateScene(UI32 creator, UI32 mod, UI32 lingerSeconds = 0,
                             UI32 maxPlayers = 0, int harden = 1, LPCREATESCENE cb = NULL, const char* params=NULL) = 0;

    // 删除对象(须在当前执行空间中进行), 不能删除玩家。 对象将在下一帧被移除
    virtual bool DeleteObject(UI32 objId) = 0;

	// 区域内查找对象
	virtual void FindObjectByArea(int left, int top, int right, int bottom,
		CMsgTyped* pResult, GameType destType = GAME_NONE) = 0;

	// 遍历场景对象
	virtual void TraverseScene(LPTRAVERSESCENEFUNC func, void* param, GameType destType = GAME_NONE) = 0;

	// 获取基本属性
	virtual UI32 GetTargetType(UI32 id) = 0;
	virtual const char* GetTargetName(UI32 id) = 0;
	virtual GameType GetTargetClass(UI32 id) = 0;
	virtual int GetTargetSex(UI32 id) = 0;

	// 遍历模板库
	// path:  "" 或 NULL 或 "/" 根目录
	// Path: "/helper/abc/"
	// recursive 是否递归
	virtual void TraverseTypeDB(LPTRAVERSETYPEDBFUN func, const char* path,  bool recursive = false, void* param = NULL) = 0;

	// 从某个目录随机选择模板号(查找时不递归)
	// 返回0 表示失败
	virtual UI32 GetRandomTypeId(const char* path) = 0;

    // 分类管理
    // 返回对象模板号的相对路径
    virtual const char* GetModPath(UI32 id) = 0;

    //判断对象的模板号是否属于次此分类， path的格式是 /helper/a/b/c/ 注意路径两端必须用 //包裹
    virtual bool BelongsTo(UI32 id, const char* path) = 0;

    // 获取接口名
    virtual const char* GetInterfaceName(UI32 id) = 0;

	// 设置基本属性
	virtual bool SetTargetName(UI32 id, const char* name) = 0;

	// 获取, 设置玩家,公共对象存储状态
	virtual bool GetSaveState(UI32 id) = 0;
	virtual bool SetSaveState(UI32 id, bool bSave) = 0;

	// 传送门相关
	virtual UI32 AddGate(SCENE_GATE* gate) = 0;// 添加门
	virtual bool DeleteGate(UI32 gateId) = 0;// 删除门
	virtual bool OpenGate(UI32 gateId) = 0;// 开启门
	virtual bool CloseGate(UI32 gateId) = 0;// 关闭门
	virtual bool FindGate(UI32 gateId, SCENE_GATE* gate) = 0;//获取门数据
	virtual void GetGateList(SCENE_GATE gates[], int& cnt) = 0;// 获取门列表
	virtual void ClearGates() = 0;// 删除全部门
	virtual size_t GetGateCount() = 0; // 获取门数据

	// 移动参数更新
	virtual bool GetPosiInfo(UI32 id, OBJ_POSI_INFO* info) = 0;
	virtual bool SetPosiInfo(UI32 id, OBJ_POSI_INFO* info, SYNC_POSI_OPT option = SPO_NONE, int reason = SR_NONE) = 0;
	virtual bool GetPosi(UI32 id, OBJ_POS* pos) = 0;
	virtual bool IsObjVisual(UI32 id) = 0;
	virtual const char* GetVisualPara(UI32 id) = 0;
	virtual bool SetPosi(UI32 id, float posi_x, float posi_y,  float posi_z,  SYNC_POSI_OPT option = SPO_NONE) = 0;
	virtual bool SetPosi(UI32 id, OBJ_POS* pos, SYNC_POSI_OPT option = SPO_NONE) = 0;
	virtual bool SetSpeed(UI32 id, float sx, float sy, float sz,  float ax, float ay,  float az, SYNC_POSI_OPT option = SPO_NONE) = 0;
	virtual bool SetSpeed(UI32 id, float sx, float sy, float ax, float ay,  SYNC_POSI_OPT option = SPO_NONE) = 0;
	virtual bool SetSpeed(UI32 id, float sx, float sy, SYNC_POSI_OPT option = SPO_NONE) = 0;
	virtual bool SetVisual(UI32 id, bool bVisual, SYNC_POSI_OPT option = SPO_NONE, int reason = SR_NONE) = 0;
	virtual bool SetVisualPara(UI32 id, const char* vPara, SYNC_POSI_OPT option = SPO_NONE) = 0;
	virtual void* GetMapInfo(UI32 id) = 0;
	virtual bool SetMapInfo(UI32 id, void* map_info) = 0;
	virtual bool SetOrient(UI32 id, float orient, SYNC_POSI_OPT option = SPO_NONE) = 0;
	virtual float GetOrient(UI32 id) = 0;// 返回-1表示失败

	// 自定义数据存储
	virtual bool SetSavePara(UI32 id, const char* savePara) = 0;
	virtual const char* GetSavePara(UI32 id) = 0;

	// 获取场景对象列表
	virtual void GetPlayerList(UI32 players[], int& size) = 0;
	virtual void GetObjectList(UI32 objects[], int& size) = 0;
	virtual size_t GetPlayerCount() = 0;
	virtual size_t GetObjectCount() = 0;
	virtual float OverLoadPercent() = 0;
	virtual const char* GetGuid(UI32 self) = 0;

	// -------------------------------------------------------------
	// 属性操作
    // 创建Cache
    virtual UI32 CreateCache(int seconds = 60) = 0;
    virtual UI32 CreateCache(UI32 cache_id, int seconds) = 0;

    // 查找Cache
    virtual bool FindCache(UI32 cache_id) = 0;

    // 删除Cache
    virtual void DeleteCache(UI32 cache_id) = 0;

	// 添加参数
    virtual bool AddPropInt(UI32 id, const char* name, int nVal = 0,
                            bool bSave = false, PROP_VISUAL visual = PV_HIDE) = 0;
	virtual bool AddPropString(UI32 id, const char* name, const char* szVal = "",
                            bool bSave = false, PROP_VISUAL visual = PV_HIDE) = 0;
	virtual bool AddPropWstr(UI32 id, const char* name, const wchar_t* wsVal = L"",
                          bool bSave = false, PROP_VISUAL visual = PV_HIDE) = 0;
	virtual bool AddPropFloat(UI32 id, const char* name, float fVal = 0.0f,
                           bool bSave = false, PROP_VISUAL visual = PV_HIDE) = 0;
	virtual bool AddPropBool(UI32 id, const char* name, bool bVal = true,
                          bool bSave = false, PROP_VISUAL visual = PV_HIDE) = 0;

	// 设置，获取参数属性
	virtual void SetSave(UI32 id, const char* name, bool bSave = true) = 0;
	virtual bool GetSave(UI32 id, const char* name) = 0;

	// 设置可视属性
	virtual void SetVisual(UI32 id, const char* name, PROP_VISUAL visual = PV_PUBLIC) = 0;
	virtual PROP_VISUAL GetVisual(UI32 id, const char* name) = 0;

	// 设置和得到其等级
	virtual void SetListener(UI32 id, const char* name, LPPROPCHANGED callback) = 0;

	// 获取参数
	virtual int GetPropInt(UI32 id, const char* name, bool* bSucc = NULL, int nDef = 0) = 0;
	virtual const char* GetPropString(UI32 id, const char* name, bool* bSucc = NULL, const char* szDef = "") = 0;
	virtual const wchar_t* GetPropWstr(UI32 id, const char* name, bool* bSucc = NULL, const wchar_t* wsDef = L"") = 0;
	virtual float GetPropFloat(UI32 id, const char* name, bool* bSucc = NULL, float fDef = 0.0f) = 0;
	virtual bool GetPropBool(UI32 id, const char* name, bool* bSucc = NULL, bool bDef = false) = 0;

	// 更新参数
	virtual bool SetPropInt(UI32 id, const char* name, int nVal, bool sync = true) = 0;
	virtual bool SetPropString(UI32 id, const char* name, const char* szVal, bool sync = true) = 0;
	virtual bool SetPropWstr(UI32 id, const char* name, const wchar_t* wsVal, bool sync = true) = 0;
	virtual bool SetPropFloat(UI32 id, const char* name, float fVal, bool sync = true) = 0;
	virtual bool SetPropBool(UI32 id, const char* name, bool bVal, bool sync = true) = 0;

	// 更新参数
	virtual bool IncPropInt(UI32 id, const char* name, int inc = 1, bool sync = true, int max = 0x7FFFFFFF) = 0;
	virtual bool IncPropFloat(UI32 id, const char* name, float inc, bool sync = true, float max = 9999999.0f) = 0;
	virtual bool DecPropInt(UI32 id, const char* name, int dec = 1, bool sync = true, int min = 0) = 0;
	virtual bool DecPropFloat(UI32 id, const char* name, float dec, bool sync = true, float min = 0.0f) = 0;

	// 删除和查找
	virtual void DeleteProp(UI32 id, const char* name) = 0;
	virtual CVar* FindProp(UI32 id, const char* name, VAR_TYPE type = VARTYPE_UNKNOWN) = 0;

	// 属性表操作
	// 创建表
	// colList: 列列表，格式如 "int,string,wstring" 则创建一个三列的表
	// initRows 创建时初始化行数
	// maxRows 最多允许的行数
	virtual bool CreateTable(UI32 id, const char* szTableName, const char* colList, size_t initRows, size_t maxRows) = 0;

	// 查找表
	virtual bool FindTable(UI32 id, const char* szTableName) = 0;

	// 删除表
	virtual void DeleteTable(UI32 id, const char* szTableName) = 0;

	// 获取表数量
	virtual size_t GetTableCount(UI32 id) = 0;

	// 获取名字
	virtual const char* GetTableName(UI32 id, int index) = 0;

	// 获取行数
	virtual size_t GetRowCount(UI32 id, const char* szTableName) = 0;

	// 获取最大行数
	virtual size_t GetMaxRowCount(UI32 id, const char* szTableName) = 0;

	// 设置最大行数
	virtual bool SetMaxRowCount(UI32 id, const char* szTableName, size_t maxRowcount) = 0;

	// 设置保存
	virtual void SetSaveTable(UI32 id, const char* szTableName, bool bSave) = 0;

	// 返回列数量
	virtual size_t GetColCount(UI32 id, const char* szTableName) = 0;

	// 是否保存
	virtual bool GetSaveTable(UI32 id, const char* szTableName) = 0;

	// 插入表(row == -1表示插在尾部), 返回插入后所在index(返回 < 0 表示插入失败)
	virtual int InsertRow(UI32 id, const char* szTableName, int row, CMsgTyped* pVarLsit = NULL) = 0;

	// 更新表
	virtual bool SetRow(UI32 id, const char* szTableName, int row, CMsgTyped& VarList) = 0;

	// 更新表的一列
	virtual bool SetRowInt(UI32 id, const char* szTableName, int row, int col, int val) = 0;
	virtual bool SetRowString(UI32 id, const char* szTableName, int row, int col, const char* val) = 0;
	virtual bool SetRowWideStr(UI32 id, const char* szTableName, int row, int col, const wchar_t* val) = 0;
	virtual bool SetRowFloat(UI32 id, const char* szTableName, int row, int col, float val) = 0;
	virtual bool SetRowBool(UI32 id, const char* szTableName, int row, int col, bool val) = 0;

	virtual bool SetRowInt(CVarRow* & row, int col, int val) = 0;
	virtual bool SetRowString(CVarRow* & row, int col, const char* val) = 0;
	virtual bool SetRowWideStr(CVarRow* & row, int col, const wchar_t* val) = 0;
	virtual bool SetRowFloat(CVarRow* & row, int col, float val) = 0;
	virtual bool SetRowBool(CVarRow* & row, int col, bool val) = 0;

	virtual bool SetRowInt(UI32 id, const char* szTableName, int row, const char* col, int val) = 0;
	virtual bool SetRowString(UI32 id, const char* szTableName, int row, const char* col, const char* val) = 0;
	virtual bool SetRowWideStr(UI32 id, const char* szTableName, int row, const char* col, const wchar_t* val) = 0;
	virtual bool SetRowFloat(UI32 id, const char* szTableName, int row, const char* col, float val) = 0;
	virtual bool SetRowBool(UI32 id, const char* szTableName, int row, const char* col, bool val) = 0;

	// 获取值
	virtual bool GetRow(UI32 id, const char* szTableName, int row, CMsgTyped& VarList) = 0;
	virtual size_t GetRows(UI32 id, const char* szTableName, int from, int to, CMsgTyped& varList) = 0;// from1,to3, 表示返回 1,2,3 3 行

	virtual int GetRowInt(UI32 id, const char* szTableName, int row, int col) = 0;
	virtual const char* GetRowString(UI32 id, const char* szTableName, int row, int col) = 0;
	virtual const wchar_t* GetRowWideStr(UI32 id, const char* szTableName, int row, int col) = 0;
	virtual float GetRowFloat(UI32 id, const char* szTableName, int row, int col) = 0;
	virtual bool GetRowBool(UI32 id, const char* szTableName, int row, int col) = 0;

	virtual int GetRowInt(UI32 id, const char* szTableName, int row, const char* col) = 0;
	virtual const char* GetRowString(UI32 id, const char* szTableName, int row, const char* col) = 0;
	virtual const wchar_t* GetRowWideStr(UI32 id, const char* szTableName, int row, const char* col) = 0;
	virtual float GetRowFloat(UI32 id, const char* szTableName, int row, const char* col) = 0;
	virtual bool GetRowBool(UI32 id, const char* szTableName, int row, const char* col) = 0;

	// 查找空行
	virtual int FindFirstEmptyRow(UI32 id, const char* szTableName) = 0;

	//查询是否空行
	virtual bool IsNull(UI32 id, const char* szTableName, int row) = 0;

	// 拷贝表
	virtual bool CopyTable(UI32 id, const char* szSrc, const char* szDest) = 0;

	// 查找指定行
	virtual int FindRow(UI32 id, const char* szTableName, int value, size_t col = 0, int* results = 0, int* resCnt = NULL) = 0;
	virtual int FindRow(UI32 id, const char* szTableName, float value, size_t col = 0, int* results = 0, int* resCnt = NULL) = 0;
	virtual int FindRow(UI32 id, const char* szTableName, const char* value, size_t col = 0, int* results = 0, int* resCnt = NULL) = 0;
	virtual int FindRow(UI32 id, const char* szTableName, const wchar_t* value, size_t col = 0, int* results = 0, int* resCnt = NULL) = 0;

	virtual int FindRowByName(UI32 id, const char* szTableName, int value, const char* col = 0, int* results = 0, int* resCnt = NULL) = 0;
	virtual int FindRowByName(UI32 id, const char* szTableName, float value, const char* col = 0, int* results = 0, int* resCnt = NULL) = 0;
	virtual int FindRowByName(UI32 id, const char* szTableName, const char* value, const char* col = 0, int* results = 0, int* resCnt = NULL) = 0;
	virtual int FindRowByName(UI32 id, const char* szTableName, const wchar_t* value, const char* col = 0, int* results = 0, int* resCnt = NULL) = 0;

	// 删除指定index的一行
	virtual void DeleteRow(UI32 id, const char* szTableName, int index) = 0;

	// 删除指定行, 但保留其index;
	virtual void ClearRow(UI32 id, const char* szTableName, int index) = 0;

	// 删除一行
	virtual void ClearRow(CVarRow* & row) = 0;

	// 删除所有行
	virtual bool DeleteAllRows(UI32 id, const char* szTableName) = 0;

	// 删除所有行，保留其数据
	virtual bool ClearAllRows(UI32 id, const char* szTableName) = 0;

	// 删除所有空行
	virtual bool DeleteAllEmptyRows(UI32 id, const char* szTableName) = 0;

	// 排序(只能对整数，浮点数列排序) col 从0 开始
	virtual bool SortTable(UI32 id, const char* szTableName, int col, bool asc = false) = 0;
	virtual bool SortTable(UI32 id, const char* szTableName, const char* col, bool asc = false) = 0;

	// 遍历表
	virtual bool TraverseTable(UI32 id, const char* szTableName, LPTRAVERSETABLEFUNC func, void* param, bool readonly) = 0;

	// 打印表
	virtual void DumpTable(UI32 id, const char* szTableName, char* buffer = NULL, size_t bufsize = 0) = 0;
};

